package com.auction.controller.admin;

import com.auction.dto.SellerApplicationPageQueryDTO;
import com.auction.pojo.PageResult;
import com.auction.pojo.Result;
import com.auction.pojo.SellerApplication;
import com.auction.service.SellerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController("adminSellerController")
@RequestMapping("/admin/seller")
public class SellerController {

    @Autowired
    private SellerService sellerService;

    /**
     * 审核卖家申请
     *
     * @param id
     * @param status
     * @return
     */
    @PostMapping("/application/{status}")
    public Result approve(@PathVariable Integer status , Long id) {
        log.info("审核卖家申请：id={}, status={}", id, status);
        sellerService.approve(id, status);
        return Result.success();
    }

    /**
     * 查询卖家申请列表
     *
     * @param pageQueryDTO
     * @return 申请列表
     */
    @GetMapping("/applications/page")
    public Result<PageResult> page(SellerApplicationPageQueryDTO pageQueryDTO) {

        log.info("分页查询卖家申请列表：参数为{}", pageQueryDTO);
        PageResult pageResult = sellerService.pageQuerySellerApplications(pageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 分页查询卖家列表
     * @param pageQueryDTO
     * @return
     */
    @GetMapping("/list")
    public Result<PageResult> list(SellerApplicationPageQueryDTO pageQueryDTO) {

        log.info("分页查询卖家列表：参数为{}", pageQueryDTO);
        PageResult pageResult = sellerService.page(pageQueryDTO);
        return Result.success(pageResult);
    }
}